package ar.edu.unq.leezsi.model;

import java.lang.reflect.Method;

import ar.edu.unq.leezsi.utils.ReflectionUtils;

public class PropertyResolver {

	private final Object target;

	public PropertyResolver(Object target) {
		this.target = target;
	}

	public <T> T get(String property) {
		Method getter = ReflectionUtils.target(this.getTarget()).getGetter(
				property);
		return ReflectionUtils.invoke(getter, this.getTarget());
	}

	public Object getTarget() {
		return this.target;
	}

	public void set(String property, Object value) {
		Method setter = ReflectionUtils.target(this.getTarget()).getSetter(
				property);
		ReflectionUtils.invoke(setter, this.getTarget(), value);
	}

}
